package com.zslc.securitymonitoring.util;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CmsResult
        implements Serializable
{
    private static final long serialVersionUID = 1L;
    private String success;
    private Map<String, Object> data = new HashMap();

    public CmsResult() {}

    public CmsResult(String success, Map<String, Object> data)
    {
        this.success = success;
        this.data = data;
    }

    public CmsResult(List list)
    {
        this.success = "true";
        this.data.put("count", Integer.valueOf(list.size()));
        this.data.put("list", list);
    }

    public CmsResult(String error, String msg)
    {
        this.success = "false";
        this.data.put("error", error);
        this.data.put("msg", msg);
    }

    public CmsResult(Map<String, Object> data)
    {
        this.success = "true";
        this.data=data;
    }

    public CmsResult(String status)
    {
        this.success = status;
    }

    public static CmsResult ok()
    {
        return new CmsResult("true");
    }


    public static CmsResult ok(String k,Object v)
    {
        CmsResult c= new CmsResult("true");
        c.getData().put(k,v);
        return c;
    }

    public static CmsResult ok(List list)
    {
        return new CmsResult(list);
    }


    public static CmsResult ok(Map<String, Object> data)
    {
        return new CmsResult(data);
    }





    public static CmsResult bulid(String error, String msg)
    {
        return new CmsResult(error, msg);
    }

    public static CmsResult bulid(String success, Map<String, Object> data)
    {
        return new CmsResult(success, data);
    }

    public String getSuccess()
    {
        return this.success;
    }

    public void setSuccess(String success)
    {
        this.success = success;
    }

    public Map<String, Object> getData()
    {
        return this.data;
    }

    public void setData(Map<String, Object> data)
    {
        this.data = data;
    }
}
